package be.ipl.finito.domaine;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import be.ipl.finito.util.Util;

@SuppressWarnings("serial")
@Entity
@Table(name = "JETONS", schema = "FINITO")
public class Jeton implements Serializable {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;
	@NotNull
	@Column(unique=true)
	private int numero;

	protected Jeton() {

	}

	public Jeton(int numero) {
		Util.checkPositive(numero);
		this.numero=numero;
	}

	public int getId() {
		return id;
	}

	public int getNumero() {
		return numero;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + numero;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Jeton other = (Jeton) obj;
		if (numero != other.numero)
			return false;
		return true;
	}
	
}
